package com.ruoyi.draw.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.draw.domain.NovelTags;
import com.ruoyi.draw.service.INovelTagsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * NovelTagsController
 * 
 * @author Locke
 * @date 2025-10-25
 */
@RestController
@RequestMapping("/novel/tags")
public class NovelTagsController extends BaseController
{
    @Autowired
    private INovelTagsService novelTagsService;

    /**
     * 查询NovelTags列表
     */
    @PreAuthorize("@ss.hasPermi('novel:tags:list')")
    @GetMapping("/list")
    public TableDataInfo list(NovelTags novelTags)
    {
        startPage();
        List<NovelTags> list = novelTagsService.selectNovelTagsList(novelTags);
        return getDataTable(list);
    }

    /**
     * 导出NovelTags列表
     */
    @PreAuthorize("@ss.hasPermi('novel:tags:export')")
    @Log(title = "NovelTags", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, NovelTags novelTags)
    {
        List<NovelTags> list = novelTagsService.selectNovelTagsList(novelTags);
        ExcelUtil<NovelTags> util = new ExcelUtil<NovelTags>(NovelTags.class);
        util.exportExcel(response, list, "NovelTags数据");
    }

    /**
     * 获取NovelTags详细信息
     */
    @PreAuthorize("@ss.hasPermi('novel:tags:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(novelTagsService.selectNovelTagsById(id));
    }

    /**
     * 新增NovelTags
     */
    @PreAuthorize("@ss.hasPermi('novel:tags:add')")
    @Log(title = "NovelTags", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody NovelTags novelTags)
    {
        return toAjax(novelTagsService.insertNovelTags(novelTags));
    }

    /**
     * 修改NovelTags
     */
    @PreAuthorize("@ss.hasPermi('novel:tags:edit')")
    @Log(title = "NovelTags", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody NovelTags novelTags)
    {
        return toAjax(novelTagsService.updateNovelTags(novelTags));
    }

    /**
     * 删除NovelTags
     */
    @PreAuthorize("@ss.hasPermi('novel:tags:remove')")
    @Log(title = "NovelTags", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(novelTagsService.deleteNovelTagsByIds(ids));
    }
}
